package com.itheima;

import com.alibaba.csp.sentinel.adapter.servlet.CommonFilter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Bean;

/**
 * @Author：shenkunlin
 * @date： 2021/7/5 11:39
 * @Description：
 ***/
@SpringBootApplication
@EnableDiscoveryClient //开启服务注册与发现
public class ItheimaApplication {

    public static void main(String[] args) {
        SpringApplication.run(ItheimaApplication.class,args);
    }

    /***
     * Sentinel过滤器
     * @return
     */
    @Bean
    public FilterRegistrationBean sentinelFilterRegistration() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(new CommonFilter());
        registration.addUrlPatterns("/*");
        // 入口资源关闭聚合
        registration.addInitParameter(CommonFilter.WEB_CONTEXT_UNIFY, "false");
        registration.setName("sentinelFilter");
        registration.setOrder(1);
        return registration;
    }
}
